package com.ttj.controller.purchaser;


import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.gson.Gson;
import com.ttj.domain.oracle.WebUser;
import com.ttj.service.WebUserService;
import com.ttj.vo.BaseRes;

@Controller
@RequestMapping("purchaser/webuser")
public class WebUserController {

	private static Logger logger = LoggerFactory.getLogger(WebUserController.class);
	
	@Resource
	private WebUserService userService;
	
	@RequestMapping(value="/check")
	public @ResponseBody BaseRes<WebUser> check(int type,String string){
		logger.debug("{}",type,string);
		return userService.createRecCheckUser(type,string);
	}
	
	@RequestMapping(value="/getUser",method=RequestMethod.GET)
	public @ResponseBody BaseRes<WebUser> getUser(int type,String str){
		return userService.getUser(type, str);
	}
	
	@RequestMapping(value="/register",method=RequestMethod.GET)
	public @ResponseBody Map<String,Object> register(String json){
		Gson gson = new Gson();
		WebUser user = gson.fromJson(json, WebUser.class);
		logger.debug(json);
		return userService.register(user);
	}
	
	@RequestMapping(value="/checkVerify",method=RequestMethod.GET)
	public @ResponseBody int checkVerify(String phone,String verify,int type){
		logger.debug(phone,verify,type);
		return userService.checkVerify(phone, verify,type);
	}
	
	@RequestMapping(value="/updAddr",method=RequestMethod.GET)
	public @ResponseBody int updUserAddr(String json,String username){
		logger.debug(json,username);
		return userService.updUserAddr(json);
	}
}
